<template>
  <div class="content-nav">
      <div class="options" ref='optionsNavRef' @click="clickHandler">
          <div class="item active">资源</div>
          <div class="item">视频课</div>
          <div class="item">直播课</div>
      </div>
  </div>

  <div class="content-data">
      <div class="search">
          <input type="text">
          <el-icon color="#7d8090" class="my-icon" size="40">
              <Search />
          </el-icon>
          <div class="btn">
              <button>搜索</button>
          </div>
      </div>
      
      <div class="data">
          <div class="desc-words">无更多内容</div>
      </div>

  </div>
</template>

<script lang="ts">
  export default {
      name: 'MediaCache'
  }
</script>

<script setup lang="ts">
  import { onMounted, ref } from 'vue';
  import { Search } from '@element-plus/icons-vue';


  const optionsNavRef = ref();

  const clickHandler = () => {
      const optionsList = optionsNavRef.value.children;
      for (let i = 0; i < optionsList.length; i++) {
          if(optionsList[i].classList.contains('item')) {
              optionsList[i].onclick = function () {
                  for (let j = 0; j < optionsList.length; j++) {
                      optionsList[j].classList.remove('active');
                  };
                  optionsList[i].classList.add('active');
              };
          };
      };
  };

  onMounted(() => {
      clickHandler();
  });
</script>

<style scoped>
button {
  border: none;
}
.content-nav {
  height: 72px;
  margin-bottom: 10px;
  background-color: #fff;
  border-radius: 5px;
}
.content-nav .options {
  height: 72px;
  display: flex;
  text-align: center;
  font-size: 14px;
  cursor: pointer;
}
.content-nav .options .item {
  padding: 28px 30px;
}
.content-nav .options .item:nth-child(1) {
  width: 37px;
}
.content-nav .options .active::after {
  content: "";
  display: block;
  margin: 21px auto 0;
  width: 37px;
  border-bottom: 5px solid #f93684;
}
.content-data {
  padding: 14px 40px 10px 31px;
  background-color: #fff;
}
.content-data .search {
  display: flex;
  position: relative;
}
.content-data .search input {
  height: 38px;
  width: 225px;
  padding: 0 15px 0 30px;
  border: 1px solid #eaecf0;
  background-color: #f5f7f9;
  border-radius: 5px;
}
.content-data .search .my-icon {
  width: 14px;
  height: 13px;
  position: absolute;
  top: 15px;
  left: 12px;
}
.content-data .search .btn {
  height: 100%;
}
.content-data .search .btn button {
  height: 40px;
  width: 62px;
  padding: 12px 0;
  margin-left: 10px;
  color: #7d8090;
  border-radius: 5px;
  background-color: #f5f7f9;
}
.content-data .data {
  height: 700px;
  padding: 0 35px 0 22px;
  margin-bottom: 20px;
}
.content-data .data .desc-words {
  height: 60px;
  text-align: center;
  line-height: 60px;
  color: #7d8090;
  border-bottom: 1px solid #eaecf0;
}

</style>